/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#pragma once
#include <引擎数据类型.h>

#include "../C_数值插座.h"

#include <map>




class C_插座Str_Array1D : public C_插座基类 {
public:
	C_插座Str_Array1D(std::wstring name);

	std::vector<std::string>	m_Value;

	void*		f_getData(uint8 线程ID);
	bool		f_getBool(uint8 线程ID = 0);
	void		f_setData(void* data, uint8 线程ID = 0);
	
	std::wstring		f_getTypeName() { return L"[str]"; }
};
#define DEF_插座Str_Array1D(socket) dynamic_cast<C_插座Str_Array1D*>( (socket) )
#define DEF_取插座Str_Array1D数据(socket) ((std::vector<string>*)(DEF_插座Str_Array1D( (socket) )->f_getData()))

#define DEF_创建Str_Array1D插座_I(name)  socket = new C_插座Str_Array1D( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建Str_Array1D插座_O(name)  socket = new C_插座Str_Array1D( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);












class C_插座I8_Array1D : public C_插座基类 {
	S_I8Array* m_默认;
	S_I8Array* m_转换;

public:
	C_插座I8_Array1D(std::wstring name);
	~C_插座I8_Array1D();

	S_I8Array*		m_Value;

	void*		f_getData(uint8 线程ID);
	void		f_setData(void* data, uint8 线程ID = 0);

	std::string	f_构建变量代码(int32 loc);
	bool		f_接入插座是否匹配(E_值类型 type);

	std::wstring		f_getTypeName() { return L"[I8]"; }
};
#define DEF_插座I8_1D(socket) dynamic_cast<C_插座I8_Array1D*>( (socket) )
#define DEF_I8插座_1D数据(socket) ((S_I8Array*)((socket)->f_getData(0)))

#define DEF_创建I8_1D插座_I(name)  socket = new C_插座I8_Array1D( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建I8_1D插座_O(name)  socket = new C_插座I8_Array1D( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);





class C_插座Bool_1D : public C_插座基类 {
	S_BoolArray* m_默认;
	S_BoolArray* m_转换;
public:
	C_插座Bool_1D(std::wstring name);

	S_BoolArray* m_Value;

	void*		f_getData(uint8 线程ID);
	void		f_setData(void* data, uint8 线程ID = 0);

	std::wstring		f_getTypeName() { return L"[bool]"; }
};
#define DEF_取插座Bool_1D数据(socket, tid) ((S_BoolArray*)(( (socket) )->f_getData(tid)))

#define DEF_创建Bool_1D插座_I(name)  socket = new C_插座Bool_1D( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建Bool_1D插座_O(name)  socket = new C_插座Bool_1D( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);






class C_Vector1D_F32插座 : public C_插座基类 {
public:
	C_Vector1D_F32插座(std::wstring name);
	~C_Vector1D_F32插座();

	std::vector<float32>		m_Value;


	void*			f_getData(uint8 线程ID);
	void			f_setData(void* data, uint8 线程ID = 0);
	
	void			f_释放数据();
	std::wstring	f_getTypeName() { return L"[F32]"; }
private:

};
#define DEF_转换为1DArray_F32插座(socket) dynamic_cast<C_Vector1D_F32插座*>( (socket) )
#define DEF_F32_Array1D插座数据(socket) ((std::vector<float32>*)((socket)->f_getData(0)))

#define DEF_创建F32_Array1D插座_I(name)	socket = new C_Vector1D_F32插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建F32_Array1D插座_O(name)	socket = new C_Vector1D_F32插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);

#define DEF_F321Dp_CP_F321Dp(t, s) *((vector<float32>*)(t)) = *((vector<float32>*)s)






class C_F32_1D插座 : public C_插座基类 {
	S_F32Array* m_默认值;
	S_F32Array* m_转换值;
public:
	C_F32_1D插座(std::wstring name);
	~C_F32_1D插座();

	S_F32Array*	m_Value;

	S_GPU内存块索引& f_getGPU块(uint8 线程ID, bool 更新 = false);
	S_GPU内存块索引& f_downGPU块(uint8 线程ID, bool 更新 = false);
	void*			f_getData(uint8 线程ID);
	void			f_setData(void* data, uint8 线程ID = 0);
	std::string	f_构建变量代码(int32 loc);
	bool		f_接入插座是否匹配(E_值类型 type);

	void		f_读取(FILE* f);
	void		f_写入(FILE* f);
	std::wstring	f_getTypeName() { return L"F32_Array"; }
private:

};
#define DEF_F32_1D插座(socket) dynamic_cast<C_F32_1D插座*>( (socket) )
#define DEF_F32插座_1D数据(socket) ((S_F32Array*)((socket)->f_getData(0)))

#define DEF_创建F32_1D插座_I(name)	socket = new C_F32_1D插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建F32_1D插座_O(name)	socket = new C_F32_1D插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);






class C_Array2D_F32插座 : public C_插座基类 {
public:
	C_Array2D_F32插座(std::wstring name);
	~C_Array2D_F32插座();

	std::vector<std::vector<float32>>		m_Value;

	void*		f_getData(uint8 线程ID);
	void		f_setData(void* data, int64 ID = -1);
	void*		f_getData(const uvec4& id);
	uvec4		f_get维度();

	std::wstring		f_getTypeName() { return L"[[F32]]"; }
	PyObject*	f_输出_bl数据(PyObject* bl_data = 0);
private:

};
#define DEF_转换为2DArray_F32插座(socket) dynamic_cast<C_Array2D_F32插座*>( (socket) )
#define DEF_取2DArray_F32插座数据(socket, tid) (std::vector<std::vector<float32>>*)((socket)->f_getData(tid))

#define DEF_2DArray_F32插座创建_I(name)  socket = new C_Array2D_F32插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_2DArray_F32插座创建_O(name)  socket = new C_Array2D_F32插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);

PyObject* f_F32_Array2D_输出_bl数据(const std::vector<std::vector<float32>>& v, PyObject* bl_data);









class C_插座I32_1D : public C_插座基类 {
	S_I32Array* m_默认值;
	S_I32Array* m_转换值;
public:
	C_插座I32_1D(std::wstring name);
	~C_插座I32_1D();

	S_I32Array*		m_Value;

	void*		f_getData(uint8 线程ID);
	void		f_setData(void* data, uint8 线程ID = 0);
	std::string	f_构建变量代码(int32 loc);
	bool		f_接入插座是否匹配(E_值类型 type);
	void		f_读取(FILE* f);
	void		f_写入(FILE* f);
	std::wstring		f_getTypeName() { return L"[I32]"; }
private:

};
#define DEF_I32插座_1D(socket) dynamic_cast<C_插座I32_1D*>( (socket) )
#define DEF_I32插座_1D数据(socket) ((S_I32Array*)(DEF_I32插座_1D( (socket) )->f_getData(0)))

#define DEF_创建I32_1D插座_I(name)  socket = new C_插座I32_1D( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建I32_1D插座_O(name)  socket = new C_插座I32_1D( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);

PyObject* f_I32_Array1D_输出_bl数据(const std::vector<int32>& v);






class C_插座I32_Array2D : public C_插座基类 {
public:
	C_插座I32_Array2D(std::wstring name);
	~C_插座I32_Array2D();

	std::vector<std::vector<int32>>		m_Value;

	void*		f_getData(uint8 线程ID);
	void		f_setData(void* data, uint8 线程ID = 0);
	std::wstring		f_getTypeName() { return L"[[I32]]"; }
private:

};
#define DEF_转换为2DArray_I32插座(socket) dynamic_cast<C_插座I32_Array2D*>( (socket) )
#define DEF_取2DArray_I32插座数据(socket, tid) (std::vector<std::vector<int32>>*)((socket)->f_getData(tid))

#define DEF_插座I32_2DArray创建_I(name)  socket = new C_插座I32_Array2D( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_插座I32_2DArray创建_O(name)  socket = new C_插座I32_Array2D( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);





class C_UI32插座_Array1D : public C_插座基类 {
	S_UI32Array* m_默认值;
	S_UI32Array* m_转换值;
public:
	C_UI32插座_Array1D(std::wstring name);
	~C_UI32插座_Array1D();

	S_UI32Array* m_Value;

	void*		f_getData(uint8 线程ID);
	void		f_setData(void* data, uint8 线程ID = 0);
	std::string	f_构建变量代码(int32 loc);
	bool		f_接入插座是否匹配(E_值类型 type);
	void		f_读取(FILE* f);
	void		f_写入(FILE* f);
	std::wstring		f_getTypeName() { return L"[UI32]"; }
};
#define DEF_转换为1DVector_UI32插座(socket) dynamic_cast<C_UI32插座_Array1D*>( (socket) )
#define DEF_UI32插座_1D数据(socket) ((S_UI32Array*)((socket)->f_getData(0)))

#define DEF_创建UI32_1D插座_I(name)  socket = new C_UI32插座_Array1D( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建UI32_1D插座_O(name)  socket = new C_UI32插座_Array1D( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);

#define DEF_UI32p_CP_UI32p(t, s) *((vector<uint32>*)(t)) = *((vector<uint32>*)s)






class C_UI32插座_Array3D : public C_插座基类 {
public:
	C_UI32插座_Array3D(std::wstring name);

	std::vector<std::vector<std::vector<uint32>>>	m_Value;

	void*		f_getData();
	void		f_setData(void* data, int64 ID = -1);
	PyObject*	f_bl_传入数据(PyObject* bl_data);
	PyObject*	f_输出_bl数据(PyObject* bl_data = 0);
	void		f_删除元素(uint32 id);
	void		f_释放数据();
	std::wstring		f_getTypeName() { return L"[[[UI32]]]"; }
};
#define DEF_转换为UI32_Array3D插座(socket) dynamic_cast<C_UI32插座_Array3D*>( (socket) )
#define DEF_取UI32_Array3D插座数据(socket) ((std::vector<std::vector<std::vector<uint32>>>*)((socket)->f_getData()))

#define DEF_创建UI32_Array3D插座_I(name)  socket = new C_UI32插座_Array3D( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建UI32_Array3D插座_O(name)  socket = new C_UI32插座_Array3D( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);







class C_数组插座 : public C_插座基类 {
	S_Array*	m_默认值;
public:
	C_数组插座(std::wstring name);
	~C_数组插座();

	S_Array*	m_Value;

	void*		f_getData(uint8 线程ID);
	void		f_setData(void* data, uint8 线程ID = 0);
	std::string	f_构建变量代码(int32 loc);
	bool		f_接入插座是否匹配(E_值类型 type);

	std::wstring	f_getTypeName() { return L"Array"; }
};
#define DEF_数组插座(socket) dynamic_cast<C_数组插座*>( (socket) )
#define DEF_数组插座数据(socket) ((S_Array*)((socket)->f_getData(0)))

#define DEF_创建数组插座_I(name)  socket = new C_数组插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建数组插座_O(name)  socket = new C_数组插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);







class C_2D数组插座 : public C_插座基类 {
	S_1DArray*	m_默认;
public:
	C_2D数组插座(std::wstring name);

	S_1DArray*	m_Value;

	void*		f_getData(uint8 线程ID);
	void		f_setData(void* data, uint8 线程ID = 0);
	std::string	f_构建变量代码(int32 loc);
	bool		f_接入插座是否匹配(E_值类型 type);

	std::wstring	f_getTypeName() { return L"[Array]"; }
};
#define DEF_1D数组插座(socket) dynamic_cast<C_2D数组插座*>( (socket) )
#define DEF_1D数组插座数据(socket) ((S_1DArray*)((socket)->f_getData()))

#define DEF_创建1D数组插座_I(name)  socket = new C_2D数组插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建1D数组插座_O(name)  socket = new C_2D数组插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);













